import unittest,requests


class MyTestCase(unittest.TestCase):
    host = 'http://10.59.9.18'
    #登录
    userId=None
    token=None
    def test_1_login(self):
        url=MyTestCase.host+'/car-user/user/v1/login'
        json={"userName":"zhangsan","passwd":"123456"}
        r=requests.post(url=url,json=json)
        print(r.json())
        MyTestCase.userId=str(r.json()['result']['userId'])
        MyTestCase.token = r.json()['result']['token']

    #查询banner列表
    def test_2_findBannerList(self):
        url = MyTestCase.host + '/car-user/user/v1/findBannerList'
        r = requests.get(url=url)
        print(r.json())
    #查询首页快捷入口导航
    def test_3_findNavigationBar(self):
        url = MyTestCase.host + '/car-user/user/v1/findNavigationBar'
        r = requests.get(url=url)
        print(r.json())
    #根据车友用户id查看车友详情
    def test_4_findCarFansInfo(self):
        url = MyTestCase.host + '/car-user/user/v1/findCarFansInfo'
        json={"carFansId":1,"page":1,"size":5}
        r = requests.get(url=url,params=json)
        print(r.json())

    #查询我的基础信息
    def test_5_getUserDetailByUid(self):
        url = MyTestCase.host + '/car-user/user/verify/v1/getUserDetailByUid'
        headers={"userId":MyTestCase.userId,"token":MyTestCase.token}
        r = requests.get(url=url,headers=headers)
        print(r.json())

    #查询近7天数据
    def test_6_findSevenDays(self):
        url = MyTestCase.host + '/car-user/user/verify/v1/findSevenDays'
        headers={"userId":MyTestCase.userId,"token":MyTestCase.token}
        r = requests.get(url=url,headers=headers)
        print(r.json())

    #查询我收藏的二手车列表
    def test_7_findCollectSecondCarList(self):
        url = MyTestCase.host + '/car-user/user/verify/v1/findCollectSecondCarList'
        headers={"userId":MyTestCase.userId,"token":MyTestCase.token}
        json={"page":"1","size":"5"}
        r = requests.get(url=url,params=json,headers=headers)
        print(r.json())

    #查询用户收藏帖子列表
    def test_8_findCollectCircleList(self):
        url = MyTestCase.host + '/car-user/user/verify/v1/findCollectCircleList'
        headers={"userId":MyTestCase.userId,"token":MyTestCase.token}
        json={"page":"1","size":"5"}
        r = requests.get(url=url,params=json,headers=headers)
        print(r.json())

    #查询我的关注列表
    def test_9_findCollectCircleList(self):
        url = MyTestCase.host + '/car-user/user/verify/v1/findAttentionList'
        headers={"userId":MyTestCase.userId,"token":MyTestCase.token}
        json={"page":"1","size":"5"}
        r = requests.get(url=url,params=json,headers=headers)
        print(r.json())

    #查询我的爱车信息 categoryId
    def test_91_getUserCarInfo(self):
        url = MyTestCase.host + '/car-user/user/verify/v1/getUserCarInfo'
        headers = {"userId": MyTestCase.userId, "token": MyTestCase.token}
        r = requests.get(url=url,headers=headers)
        print(r.json())

    # 查询汽车级别列表 gradeId
    gradeId=None
    def test_92_findCarGradeList(self):
        url = MyTestCase.host + '/car-choose/car/v1/findCarGradeList'
        headers = {"userId": MyTestCase.userId, "token": MyTestCase.token}
        r = requests.get(url=url, headers=headers)
        print(r.json())
        MyTestCase.gradeId=r.json()['result'][0]['gradeId']
    #查询销量排行榜
    def test_93_findSalesRanking(self):
        url = MyTestCase.host + '/car-choose/car/v1/findSalesRanking'
        json={"gradeId":MyTestCase.gradeId}
        r = requests.get(url=url, params=json)
        print(r.json())

    #查询汽车级别列表
    def test_94_findCarGradeList(self):
        url = MyTestCase.host + '/car-choose/car/v1/findCarGradeList'
        r = requests.get(url=url)
        print(r.json())

    #查询保值排行榜
    categoryId=None
    def test_95_findKeepValueRanking(self):
        url = MyTestCase.host + '/car-choose/car/v1/findKeepValueRanking'
        json={"gradeId":MyTestCase.gradeId}
        r = requests.get(url=url, params=json)
        print(r.json())
        MyTestCase.categoryId=r.json()['result'][0]['categoryId']

    #查询降价排行榜
    def test_96_findDepreciateRanking(self):
        url = MyTestCase.host + '/car-choose/car/v1/findDepreciateRanking'
        json = {"gradeId": MyTestCase.gradeId}
        r = requests.get(url=url, params=json)
        print(r.json())

    #查询二手车销量排行榜
    def test_97_findSecondCarRanking(self):
        url = MyTestCase.host + '/car-choose/car/v1/findSecondCarRanking'
        json = {"gradeId": MyTestCase.gradeId}
        r = requests.get(url=url, params=json)
        print(r.json())

    #获取汽车vr全景图图片资源
    def test_98_categoryId(self):
        url = MyTestCase.host + '/car-choose/car/v1/getCarVrMedia/{categoryId}'
        json = {"categoryId": MyTestCase.categoryId}
        r = requests.get(url=url, json=json)
        print(r.json())

    #获取汽车立体模型文件资源
    def test_99_categoryId(self):
        url = MyTestCase.host + '/car-choose/car/v1/getCarSpatialModelMedia/{categoryId}'
        json = {"categoryId": MyTestCase.categoryId}
        r = requests.get(url=url, data=json)
        print(r.json())

    #关注车友  /car-user/user/verify/v1/attentionCarFans
    def test_991_attentionCarFans(self):
        url = MyTestCase.host + '/car-user/user/verify/v1/attentionCarFans'
        headers={"userId":MyTestCase.userId,"token":MyTestCase.token}
        json = {"friend":1}
        r = requests.put(url=url, data=json,headers=headers)
        print(r.json())

    #取消关注车友
    def test_992_cancelAttention(self):
        url = MyTestCase.host + '/car-user/user/verify/v1/cancelAttention'
        headers={"userId":MyTestCase.userId,"token":MyTestCase.token}
        json = {"friend":1}
        r = requests.delete(url=url, data=json,headers=headers)
        print(r.json())

    #解绑我的爱车
    def test_993_removeUserCar(self):
        url = MyTestCase.host + '/car-user/user/verify/v1/removeUserCar'
        headers = {"userId": MyTestCase.userId, "token": MyTestCase.token}
        r = requests.delete(url=url,headers=headers)
        print(r.json())

    #查询我的爱车信息
    def test_994_getUserCarInfo(self):
        url = MyTestCase.host + '/car-user/user/verify/v1/getUserCarInfo'
        headers = {"userId": MyTestCase.userId, "token": MyTestCase.token}
        r = requests.get(url=url,headers=headers)
        print(r.json())

    #查询我的发帖列表
    def test_995_findCircleListByType(self):
        url = MyTestCase.host + '/car-user/user/verify/v1/findCircleListByType'
        headers = {"userId": MyTestCase.userId, "token": MyTestCase.token}
        json={"page":"1","size":"5","type":1}
        r = requests.get(url=url,params=json,headers=headers)
        print(r.json())

    #查询我的问答列表
    def test_996_findMyProblemList(self):
        url = MyTestCase.host + '/car-user/user/verify/v1/findMyProblemList'
        headers = {"userId": MyTestCase.userId, "token": MyTestCase.token}
        json={"page":"1","size":"5"}
        r = requests.get(url=url,params=json,headers=headers)
        print(r.json())

    #查询推荐车圈列表
    def test_997_findCircleRecommendList(self):
        url = MyTestCase.host + '/car-circle/circle/v1/findCircleRecommendList'
        json = {"page": "1", "size": "5"}
        r = requests.get(url=url, params=json)
        print(r.json())

    #查询新能源车圈列表
    def test_998_findCircleNewEnergyList(self):
        url = MyTestCase.host + '/car-circle/circle/v1/findCircleNewEnergyList'
        json = {"page": "1", "size": "5"}
        r = requests.get(url=url, params=json)
        print(r.json())

    #查询关注车圈列表
    def test_999_findCircleAttentionList(self):
        url = MyTestCase.host + '/car-circle/circle/verify/v1/findCircleAttentionList'
        headers = {"userId": MyTestCase.userId, "token": MyTestCase.token}
        json = {"page": "1", "size": "5"}
        r = requests.get(url=url, params=json,headers=headers)
        print(r.json())

    #查询车圈详情
    def test_9991_getCircleDetail(self):
        url = MyTestCase.host + '/car-circle/circle/v1/getCircleDetail'
        headers = {"userId": MyTestCase.userId, "token": MyTestCase.token}
        json = {"circleId": 1}
        r = requests.get(url=url, params=json,headers=headers)
        print(r.json())

    #查询我加入的车友圈专区
    def test_9992_findMyColumnList(self):
        url = MyTestCase.host + '/car-circle/circle/verify/v1/findMyColumnList'
        headers = {"userId": MyTestCase.userId, "token": MyTestCase.token}
        r = requests.get(url=url,headers=headers)
        print(r.json())

    #广场根据关键词搜索
    def test_9993_circleSearch(self):
        url = MyTestCase.host + '/car-circle/circle/v1/circleSearch'
        json = {"keyword":"a","page": "1", "size": "5"}
        r = requests.get(url=url,data=json)
        print(r.json())

    #发表车友圈帖子评论
    def test_9994_publishComment(self):
        url = MyTestCase.host + '/car-circle/circle/verify/v1/publishComment'
        headers = {"userId": MyTestCase.userId, "token": MyTestCase.token}
        json = {"circleId":1,"content": "评论内容", "publishLocation": "所属地"}
        r = requests.post(url=url,data=json,headers=headers)
        print(r.json())

    #查询品牌列表
    def test_9995_findBrandList(self):
        url = MyTestCase.host + '/car-choose/car/v1/findBrandList'
        r = requests.get(url=url)
        print(r.json())

    #查询默认筛选条件
    def test_9996_findDefaultCondition(self):
        url = MyTestCase.host + '/car-choose/car/v1/findDefaultCondition'
        r = requests.get(url=url)
        print(r.json())

    #查询全部筛选条件
    def test_9997_findAllCondition(self):
        url = MyTestCase.host + '/car-choose/car/v1/findAllCondition'
        r = requests.get(url=url)
        print(r.json())

    #查询汽车车系明细
    def test_9998_findCarModelDetail(self):
        url = MyTestCase.host + '/car-choose/car/v1/findCarModelDetail'
        json={"categoryId":1}
        r = requests.get(url=url,params=json)
        print(r.json())

    #查询汽车参数配置明细（参数对比调用）
    def test_9999_findCarParameterList(self):
        url = MyTestCase.host + '/car-choose/car/v1/findCarParameterList'
        json={"carId":1}
        r = requests.get(url=url,params=json)
        print(r.json())

    #批量查询参数配置明细（参数对比调用）
    def test_99991_batchFindCarParameterList(self):
        url = MyTestCase.host + '/car-choose/car/v1/batchFindCarParameterList'
        json={"carIds":1}
        r = requests.get(url=url,params=json)
        print(r.json())

    #查询热门话题
    def test_99992_findHotTopicList(self):
        url = MyTestCase.host + '/car-circle/circle/v1/findHotTopicList'
        r = requests.get(url=url)
        print(r.json())

    #根据话题id查询话题详情
    def test_99993_findHotTopicById(self):
        url = MyTestCase.host + '/car-circle/circle/v1/findHotTopicById'
        json={"hotId":"1"}
        r = requests.get(url=url,data=json)
        print(r.json())

    #获取问答累计信息
    

#执行
if __name__ == '__main__':
    unittest.main()
